package com.songcha.module_mine.ui.activity.feedback

import android.os.Bundle
import com.songcha.library_base.mvvm.base.BaseMvvmActivity
import com.songcha.library_common.util.ToastUtil
import com.songcha.module_mine.R
import com.songcha.module_mine.databinding.MineActivityFeedbackBinding

class FeedbackActivity:BaseMvvmActivity<FeedbackViewModel,MineActivityFeedbackBinding>() {

    override fun getLayoutId(): Int {
        return R.layout.mine_activity_feedback
    }


    override fun isImmerseStatusBar(): Boolean {
        return true
    }

    override fun initView(savedInstanceState: Bundle?) {
        super.initView(savedInstanceState)
        databinding.mineBtnFeedback.setOnClickListener {
            commitFeedback()
        }
        viewModel.feedbackState.observe(this){data->
            if(data){
                ToastUtil.show("感谢您的反馈")
            }
        }
    }

    private fun commitFeedback(){
        val content=databinding.mineEdtFeedback.text.toString().trim()
        if(content.isBlank()){
            ToastUtil.show("请输入意见")
            return
        }
        if(content.length>200){
            ToastUtil.show("意见反馈不能超过200个字符")
            return
        }
        viewModel.commitFeedback(content)
    }

}